package com.lxb;

import java.util.ArrayList;
import java.util.Stack;

public class AddTwoNumbers {
    public static void main(String[] args) {

        ListNode head = new ListNode(9);
        ListNode first = new ListNode(4);
        head.next = first;
        ListNode second = new ListNode(3);
        first.next = second;

        ListNode head2 = new ListNode(1);
        ListNode first2 = head2;


        ListNode cur1 = head;
        String s1 = "";
        while (cur1 != null){
            s1 = cur1.val+"" + s1;
            cur1 = cur1.next;
        }

        ListNode cur2 = head2;
        String s2 = "";
        while (cur2 != null){
            s2 = cur2.val+"" + s2;
            cur2 = cur2.next;
        }

        int num = Integer.parseInt(s1)+Integer.parseInt(s2);
        String num_str = String.valueOf(num);


        Stack<Integer> stack = new Stack<Integer>();
        for (int i =0;i<num_str.length();i++){
            stack.push(Integer.parseInt(num_str.charAt(i)+""));
        }


        int stack_size = stack.size();
        ListNode node = new ListNode(stack.pop());
        ListNode cur = node;
        while(stack_size > 1){
            ListNode n = new ListNode(stack.pop());
            cur.next = n;
            cur = cur.next;
            stack_size--;
        }

        System.out.println("hello");
    }
}
